Skip to content

fix(#248): ARM64 Linux auto-fallback to Firefox + --browser CLI flag#467

Open
giulio-leone wants to merge 2 commits intovercel-labs:mainfrom
giulio-leone:fix/248-arm64-firefox
Open

fix(#248): ARM64 Linux auto-fallback to Firefox + --browser CLI flag#467
giulio-leone wants to merge 2 commits intovercel-labs:mainfrom
giulio-leone:fix/248-arm64-firefox

Conversation

@giulio-leone
Copy link
Contributor

Closes #248

Problem

Chromium is not available for ARM64 Linux (aarch64). Playwright fails with 'Chromium distribution not found'.

Solution

  1. Auto-fallback: When chromium is requested on ARM64 Linux, automatically use Firefox instead (with a warning)
  2. --browser flag: New CLI flag to explicitly choose browser engine (chromium, firefox, webkit)
  3. Env var: AGENT_BROWSER_BROWSER for configuration

Usage

# Explicit Firefox
agent-browser --browser firefox open https://example.com

# Auto-fallback on ARM64 Linux (no flag needed)
agent-browser open https://example.com  # Uses Firefox automatically

@vercel
Copy link
Contributor

vercel bot commented Feb 13, 2026

@g97iulio1609 is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

… flag

- Auto-detect ARM64 Linux and fall back to Firefox when Chromium unavailable
- Add --browser CLI flag to explicitly select browser engine
- Pass AGENT_BROWSER_BROWSER env var through daemon
- Emit warning when falling back to Firefox
Copilot AI review requested due to automatic review settings March 1, 2026 06:16
@giulio-leone giulio-leone force-pushed the fix/248-arm64-firefox branch from 1cfaf9c to 19e78a1 Compare March 1, 2026 06:16
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds browser selection support and an ARM64 Linux compatibility fallback so agent-browser can run on aarch64 where Playwright Chromium binaries may be unavailable.

Changes:

  • Auto-fallback from Chromium to Firefox on ARM64 Linux (with a launch warning).
  • Introduce a --browser CLI flag and forward browser choice to the daemon via env var.
  • Wire daemon-side auto-launch to read the browser choice from environment.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/daemon.ts Reads AGENT_BROWSER_BROWSER and forwards browser into auto-launch options.
src/browser.ts Implements ARM64 Linux Chromium → Firefox fallback and warning collection.
cli/src/main.rs Passes browser from parsed flags into daemon startup options.
cli/src/flags.rs Adds browser and cli_browser fields; updates arg cleaning/config pre-parse lists.
cli/src/connection.rs Forwards browser option to daemon via AGENT_BROWSER_BROWSER.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

// Auto-fallback to Firefox on ARM64 Linux where Chromium is unavailable
if (effectiveBrowser === 'chromium' && process.arch === 'arm64' && process.platform === 'linux') {
effectiveBrowser = 'firefox';
this.launchWarnings.push('Chromium unavailable on ARM64 Linux; using Firefox instead');
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fallback warning is only pushed into launchWarnings but (unlike other warnings in this method) it isn’t printed to stderr. As a result, users running the daemon directly (or any client that doesn’t surface data.warnings) may never see the warning. Consider also emitting it via console.error('[WARN] ...') for consistency with the other warnings above.

Suggested change
this.launchWarnings.push('Chromium unavailable on ARM64 Linux; using Firefox instead');
const warning = 'Chromium unavailable on ARM64 Linux; using Firefox instead';
this.launchWarnings.push(warning);
console.error(`[WARN] ${warning}`);

Copilot uses AI. Check for mistakes.
Comment on lines +290 to +292
if let Some(b) = opts.browser {
cmd.env("AGENT_BROWSER_BROWSER", b);
}
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR description calls out an env var AGENT_BROWSER_BROWSER_BROWSER, but the implementation sets/reads AGENT_BROWSER_BROWSER. Please align the PR description (or the env var name) to avoid shipping misleading configuration docs.

Copilot uses AI. Check for mistakes.
Comment on lines 234 to 240
pub allowed_domains: Option<Vec<String>>,
pub action_policy: Option<String>,
pub confirm_actions: Option<String>,
pub confirm_interactive: bool,
pub browser: Option<String>,
pub cli_browser: bool,

Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

browser / cli_browser fields were added to Flags, but parse_flags never initializes them in the Flags { ... } literal (so this won’t compile) and there is no match arm to parse the new --browser flag / AGENT_BROWSER_BROWSER env var into flags.browser. Please add the missing struct fields to the initializer and implement parsing (including setting cli_browser = true when --browser is provided).

Copilot uses AI. Check for mistakes.

const ignoreHTTPSErrors = process.env.AGENT_BROWSER_IGNORE_HTTPS_ERRORS === '1';
const allowFileAccess = process.env.AGENT_BROWSER_ALLOW_FILE_ACCESS === '1';
const browserType = process.env.AGENT_BROWSER_BROWSER as 'chromium' | 'firefox' | 'webkit' | undefined;
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

process.env.AGENT_BROWSER_BROWSER as ... is a compile-time cast only; at runtime any string can flow through here. If the env var is set to an unexpected value (typo, casing, etc.) it will silently behave as Chromium later. Please validate the value against the allowed set ('chromium' | 'firefox' | 'webkit') and either ignore it with a warning or return an error.

Suggested change
const browserType = process.env.AGENT_BROWSER_BROWSER as 'chromium' | 'firefox' | 'webkit' | undefined;
const browserEnv = process.env.AGENT_BROWSER_BROWSER;
let browserType: 'chromium' | 'firefox' | 'webkit' | undefined;
if (browserEnv === 'chromium' || browserEnv === 'firefox' || browserEnv === 'webkit') {
browserType = browserEnv;
} else {
if (browserEnv) {
console.warn(
`Invalid AGENT_BROWSER_BROWSER value "${browserEnv}". Expected one of "chromium", "firefox", or "webkit"; falling back to default.`
);
}
browserType = undefined;
}

Copilot uses AI. Check for mistakes.
src/browser.ts Outdated
Comment on lines 1313 to 1314
// Auto-fallback to Firefox on ARM64 Linux where Chromium is unavailable
if (effectiveBrowser === 'chromium' && process.arch === 'arm64' && process.platform === 'linux') {
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-fallback currently always forces Firefox on arm64 Linux even when the user may have a working Chromium via executablePath (or a future Playwright build adds support). Consider attempting the requested browser first and only falling back when launch fails with the specific “Chromium distribution not found”/unsupported-platform error, so arm64 users with a valid Chromium aren’t prevented from using it.

Suggested change
// Auto-fallback to Firefox on ARM64 Linux where Chromium is unavailable
if (effectiveBrowser === 'chromium' && process.arch === 'arm64' && process.platform === 'linux') {
// Auto-fallback to Firefox on ARM64 Linux where the bundled Chromium is unavailable.
// If the user has provided an explicit executablePath for Chromium, honor that choice.
if (
effectiveBrowser === 'chromium' &&
process.arch === 'arm64' &&
process.platform === 'linux' &&
!options.executablePath
) {

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ARM64 Architecture Support: Chromium Not Available on aarch64

2 participants